package shizhong;

import java.util.Calendar;

public class TimerThread implements Runnable {
    private TimerPanel tp;

    public TimerThread(TimerPanel tp) {
        this.tp = tp;
    }

    @Override
    public void run() {

        while (true) {
            Calendar c = Calendar.getInstance();
            tp.second = c.get(Calendar.SECOND);
            tp.minute = c.get(Calendar.MINUTE);
            tp.hour = c.get(Calendar.HOUR);
            tp.repaint();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}
